<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<!DOCTYPE html>
<html>
<head>
    <title></title>

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 引入bootstrap -->
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/common.css">
    <!-- 引入JQuery  bootstrap.js-->
    <script src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrapValidator.min.js"></script>
    <script src="${pageContext.request.contextPath}/layer/layer.js"></script>
    <script>
        $(function () {
            //服务端提示消息
            var successMsg='${successMsg}';
            var errorMsg='${errorMsg}';
            if(successMsg.trim() != '') {
                console.log(successMsg);
                layer.msg(successMsg,{
                    time:1000,
                    skin:'successMsg'
                });
            }
            if(errorMsg.trim() != '') {
                console.log(errorMsg);
                layer.msg(errorMsg,{
                    time:1500,
                    skin:'errorMsg'
                });
            }
            $('#addfrom').bootstrapValidator({
                feedbackIcons:{
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields:{
                    courseID:{
                        validators:{
                            notEmpty:{
                                massage:'课程ID不能为空'
                            },
                            remote:{
                                url:'${pageContext.request.contextPath}/admin/checkCourseID'
                            }
                        }
                    },
                    courseName:{
                        validators:{
                            notEmpty:{
                                massage:'课程名称不能为空'
                            }
                        }
                    },
                    courseTime:{
                        validators:{
                            notEmpty:{
                                massage:'请输入上课时间'
                            }
                        }
                    },
                    classRoom:{
                        validators:{
                            notEmpty:{
                                massage:'请输入上课地点'
                            }
                        }
                    },
                    courseWeek:{
                        validators:{
                            notEmpty:{
                                massage:'请输入该课程需上课的周数'
                            }
                        }
                    },
                    score:{
                        validators:{
                            notEmpty:{
                                massage:'请输入该课程的学分'
                            }
                        }
                    }
                }
            });
        });

    </script>
</head>
<body>
<jsp:include page="top.jsp"/>
<!-- 中间主体 -->
<div class="container" id="content">
    <div class="row">
        <div class="col-md-2">
            <jsp:include page="menu.jsp"/>
        </div>
        <div class="col-md-10">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <div class="row">
                        <h1 style="text-align: center;">添加课程信息</h1>
                    </div>
                </div>
                <div class="panel-body">
                    <form class="form-horizontal" role="form"
                          action="${pageContext.request.contextPath}/admin/addCourse" id="addfrom" method="post">
                        <div class="form-group">
                            <label for="inputEmail3" class="col-sm-2 control-label">课程号</label>
                            <div class="col-sm-10">
                                <input type="number" class="form-control" id="inputEmail3" name="courseID"
                                       placeholder="请输入课程号">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputPassword3" class="col-sm-2 control-label">课程名称</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="inputPassword3" name="courseName"
                                       placeholder="请输入课程名称">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputPassword3" class="col-sm-2 control-label" name="grade">授课老师编号</label>
                            <div class="col-sm-10">
                                <select class="form-control" name="teacherID">
                                    <c:forEach items="${teachers}" var="teacher">
                                        <option value="${teacher.userID}">${teacher.userName}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputPassword3" class="col-sm-2 control-label">上课时间</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="courseTime" placeholder="请输入上课时间">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputPassword3" class="col-sm-2 control-label">上课地点</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="classRoom" placeholder="上课地点">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputEmail3" class="col-sm-2 control-label">周数</label>
                            <div class="col-sm-10">
                                <input type="number" class="form-control" name="courseWeek" placeholder="请输入周数">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputPassword3" class="col-sm-2 control-label" name="courseType">课程的类型：</label>
                            <div class="col-sm-10">
                                <select class="form-control" name="courseType">
                                    <option value="必修课">必修课</option>
                                    <option value="选修课">选修课</option>
                                    <option value="公共课">公共课</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputPassword3" class="col-sm-2 control-label" name="grade">所属院系</label>
                            <div class="col-sm-10">
                                <select class="form-control" name="colleageID">
                                    <c:forEach items="${colleges}" var="college">
                                        <option value="${college.collegeID}">${college.collegeName}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputEmail3" class="col-sm-2 control-label">学分：</label>
                            <div class="col-sm-10">
                                <input type="number" class="form-control" name="score" placeholder="请输入学分">
                            </div>
                        </div>
                        <div class="form-group" style="text-align: center">
                            <button class="btn btn-default" type="submit">提交</button>
                            <button class="btn btn-default" type="reset">重置</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="container" id="footer">
    <div class="row">
        <div class="col-md-12"></div>
    </div>
</div>
</body>
<script type="text/javascript">
    $("#nav li:nth-child(1)").addClass("active")
</script>
</html>